<!DOCTYPE html>
<html class="no-js">
<head lang="en">

    <#include "../head_import.html" />

</head>
<body>
<#include "../include/top_nav.html">
    <div class="am-cf admin-main">

        <!-- sidebar start -->
        <#include "../adspace/left.html">
            <!-- sidebar end -->
            <!-- content start-->
            <div class="admin-content">
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><@s.m "global.position"/>: 扩展属性  - <@s.m "global.edit"/></div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <form class="ropt">
                            <input type="button" value="<@s.m "global.backToList"/>" onclick="history.back();"/>
                        </form>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <@p.form id="baseForm" action="o_update.do">
                        <@p.text label="名称" colspan="1" width="50" name="name" value=exended.name required="true" class="required" maxlength="100"/>
                        <@p.text label="字段名称" colspan="1" width="50" name="field" value=exended.field required="true" class="required" maxlength="100"/><@p.tr/>
                        <@p.select label="数据类型" colspan="1" width="50" id="dataType"  required="true" value="${exended.dataType}" list={"1":"下拉列表","2":"单选框"} name="dataType"/>
                        <@p.text label="排序"  colspan="2" width="100" name="priority" value="${exended.priority}" required="true" class="required digits" maxlength="10"/><@p.tr/>
                        <@p.checkboxlist label="关联商品类型" colspan="2" width="100" name="typeIds" valueList=typeIds list=ptList listKey="id" listValue="name" required="true" class="required"/><@p.tr/>
                        <@p.td colspan="2">
                        <div class="items">
                            &nbsp; <input type="button" value="增加属性值" onclick="addLines();"/>
                        </div>
                        <div id="itemsContainer">
                            <#list list as item>
                                <div class="items">
                                    属性值  : <input type="text" name="itemName" value="${item.name!}" style="width:200px"/>
                                    &nbsp; <input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="$(this).parent().remove();"/>
                                    <input type="hidden" name="itemId" value="${item.id}"/>
                                </div>
                            </#list>
                        </div>
                    </@p.td><@p.tr/>
                    <@p.td colspan="2" width="100">
                    <@p.hidden name="id" value=exended.id/>
                    <@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/></@p.td>
            </@p.form>
            </div>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-sm-centered">
            <textarea id="itemTpl" style="display:none;">
                <div class="items">
                    属性值 : <input type="text" name="itemName" style="width:200px"/>
                    &nbsp; <input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="$(this).parent().remove();"/>
                </div>
            </textarea>
        </div>
    </div>


    </div>

    </div>

<script type="text/javascript">
$(function() {
	<#list list as item>
	$("#itemColor${item_index}").colorPicker();
	</#list>
	$("#baseForm").validate();
	
});

var tpl = $.format($("#itemTpl").val());
var index = ${list?size}+1;
function addLines() {
	$("#itemsContainer").append(tpl(index++));
	$("#itemColor"+(index-1)).colorPicker();
}
</script>
</body>
</html>